import { renderToString } from 'vue/server-renderer';
import { setup } from '@css-render/vue3-ssr';
import { createApp } from '@/main';

export async function render(url: string) {
  const { app, router } = createApp();
  const ctx = {};

  router.push(url);
  await router.isReady();

  const { collect } = setup(app);
  const html = await renderToString(app, ctx);
  const css = collect();

  return { html, css };
}
